﻿using System;
using System.Collections.Generic;
using System.Linq;
using Mono.Cecil;
using ProjScan.RecordManager;
using ProjScan.RecordManager.AssetData;
using ProjScan.ScanRule.Attr;
using ProjScan.Submodules.CS_Check;
using ProjScan.Tools;

namespace ProjScan.ScanRule.CodeAnalysis
{
	// Token: 0x0200021F RID: 543
	[CSCheckRuleAttr]
	internal class OnGUIUsage : RecordRuleImp<TypeDefinitionAssetData, TypeDefinitionRecordManager>
	{
		// Token: 0x1700035A RID: 858
		// (get) Token: 0x06000F65 RID: 3941 RVA: 0x0000719A File Offset: 0x0000539A
		public override bool HasWhiteList
		{
			get
			{
				return false;
			}
		}

		// Token: 0x06000F66 RID: 3942 RVA: 0x00044094 File Offset: 0x00042294
		protected override string GetFailedColumn()
		{
			return "路径行号";
		}

		// Token: 0x06000F67 RID: 3943 RVA: 0x0000A3A0 File Offset: 0x000085A0
		public override bool HasFailedInfos()
		{
			return true;
		}

		// Token: 0x06000F68 RID: 3944 RVA: 0x000440AC File Offset: 0x000422AC
		protected override string GetDetailCSVHeader()
		{
			return "Class,路径行号";
		}

		// Token: 0x06000F69 RID: 3945 RVA: 0x000440C4 File Offset: 0x000422C4
		protected override string GetDetailInfo(TypeDefinitionAssetData assetData, string failedInfo)
		{
			return base.GetDetailInfo(assetData, failedInfo) + failedInfo;
		}

		// Token: 0x06000F6A RID: 3946 RVA: 0x000448C0 File Offset: 0x00042AC0
		protected override bool IsOK(TypeDefinitionAssetData assetData, ref string failedInfo)
		{
			TypeDefinition typeDefinition = assetData.typeDefinition;
			List<MethodDefinition> list = Enumerable.ToList<MethodDefinition>(typeDefinition.Methods);
			for (int i = 0; i < list.Count; i++)
			{
				bool flag = list[i].Name == "OnGUI";
				if (flag)
				{
					LineMapping lineMapping = null;
					try
					{
						bool hasBody = list[i].HasBody;
						if (hasBody)
						{
							lineMapping = LineMapping.GetMapping(list[i], list[i].Body.Instructions[0]);
						}
						else
						{
							lineMapping = null;
						}
					}
					catch (Exception exception_)
					{
						ScanLog.Instance.LogException(exception_, typeDefinition.FullName + "." + list[i].FullName + "[Cant get GetInstLocation]", "");
					}
					bool flag2 = lineMapping != null && !string.IsNullOrEmpty(lineMapping.ToString());
					if (flag2)
					{
						failedInfo = lineMapping.ToString() + AssemblyTools.I.GetAppendFullName(assetData.typeDefinition);
					}
					else
					{
						failedInfo = "Unknown";
					}
					return false;
				}
			}
			return true;
		}
	}
}
